package com.magic.gre.mvp.presenter;

import com.google.gson.reflect.TypeToken;
import com.magic.gre.entity.WordsBean;
import com.magic.gre.entity.base.BaseListModel;
import com.magic.gre.mvp.contract.NewWordsContract;
import com.magic.gre.mvp.model.NewWordsModelImpl;
import com.noname.lib_base_java.mvp.BasePresenterImpl;

/**
 * Author: Lmoumou
 * Date: 2019-01-07 17:46
 * 文件名: NewWordsPresenterImpl
 * 描述:
 */
public class NewWordsPresenterImpl extends BasePresenterImpl<NewWordsContract.View, NewWordsContract.Model>
        implements NewWordsContract.Presenter {
    public NewWordsPresenterImpl(NewWordsContract.View view) {
        super(view);
    }

    @Override
    protected NewWordsContract.Model creatModel() {
        return new NewWordsModelImpl();
    }

    @Override
    public void pNewWordsList(int pageNo) {
        mModel.mNewWordsList(new CommonObserver<BaseListModel<WordsBean>>(new TypeToken<BaseListModel<WordsBean>>(){}.getType()) {
            @Override
            protected void onSuccess(BaseListModel<WordsBean> wordsBeanBaseListModel) {
                mView.hideLoadDialog();
                mView.vNewWordsList(wordsBeanBaseListModel.body);
            }

            @Override
            public void onError(int status, String msg) {
                mView.hideLoadDialog();
            }
        }, pageNo);
    }
}
